using System;
using System.Linq;
using AndyPike.Presentations.IntroToTDD.Interfaces;

namespace AndyPike.Presentations.IntroToTDD
{
    public class StringReverserUsingLinq : IReverser<string>
    {
        private readonly ILogger logger;

        public StringReverserUsingLinq(ILogger logger)
        {
            if (logger == null)
                throw new ArgumentNullException("logger");

            this.logger = logger;
        }

        public string Reverse(string input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            var output = new string(input.Reverse().ToArray());

            logger.Info(string.Format("The string '{0}' was reversed to '{1}'.", input, output));

            return output;
        }
    }
}